package org.dey.controller;

import org.dey.pojo.Assessment;
import org.dey.pojo.PageVo;
import org.dey.service.AssessmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class AssessmentController {
    @Autowired
    AssessmentService assessmentService;

    @GetMapping("Assessment.action/{pageNum}/{pageSize}")
    public PageVo<Assessment> queryAssessment(Assessment assessment,
                                              @PathVariable int pageNum,
                                              @PathVariable int pageSize) {

        PageVo<Assessment> queryuser = assessmentService.queryAssessment(assessment, pageNum, pageSize);
        return queryuser;
    }

    //添加
    @PostMapping("addAssessment.action")
    public int insertAssessment(@RequestBody Assessment assessment) {

        int insertuser = assessmentService.insertAssessment(assessment);

        return insertuser;
    }

    @DeleteMapping("delAssessment.action/{id}")
    public int deleteAssessment(@PathVariable int id) {
        return assessmentService.deleteAssessment(id);
    }

    @GetMapping("qureyAssessmentById.action/{id}")
    public Assessment queryAssessmentByid(@PathVariable int id) {
        return assessmentService.queryAssessmentByid(id);
    }

    @PutMapping("updateAssessment.action")
    public int updateAssessment(@RequestBody Assessment assessment) {
        return assessmentService.updateAssessment(assessment);
    }
}
